package com.albert.code.style;

import lombok.Data;

public class SimplifyCode {
    public static final int targetSalary = 20000;
    private String sexInfo;

    // 三种简化代码（提高可读性）的方式
    // - extract/inline
    // - change signature
    // - rename

    public void printInfo(){
        System.out.println("简化代码");
        XiaoMing xiaoMing = new XiaoMing("XiaoMing", "male");
        System.out.println("name:" + xiaoMing.getName());
        System.out.println("age" + xiaoMing.getAge());
        System.out.println("期望工资是：" + 20000 + "元");
        System.out.println("名字的长度：" + xiaoMing.getName().length());

        printSex(xiaoMing, "未婚");
    }

    private void printSex(XiaoMing xiaoMing, final String marriageStatus) {
        switch (xiaoMing.getSex()){
            case "male":
                sexInfo = "此人性别是";
                System.out.println(sexInfo + "：男，" + marriageStatus);
            case "female":
                System.out.println(sexInfo + "：女性，" + marriageStatus);
            default:
                System.out.println(sexInfo + "：跨性别，" + marriageStatus);
        }
    }

    @Data
    public static class XiaoMing{
        private String name;
        private Integer age;
        private String sex;
        private String salary;

        //change signature
        XiaoMing(String name, String sex){
            this.name = name;
        }
    }
}
